Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

231
Vistas
FIRESTORE | How to fetch creator doc with creator_id in multi posts

I'm a newbie to try firestore .In javascript (vue) i fetched multi posts doc from firestore

How do I retrieve data from another collection by id? when i use creator_id to fetch creator collection from author function it will be Promiss or underfild alert from return

db.firestore().collection.collection("articles")
    .where("status", "==", 1)
    .orderBy("time","desc")
    .get()
    .then(snap => {
      snap.forEach(doc => {
        var post = {};
        var article = doc.data();
        post.id = doc.id;
        post.creator = article.creator_id
        ----- data ----
        this.posts.push(post);
      });

output : [{id:"",txt:"",creator_id:"this id i will use it"},{},{},{},...]

From this code I need to retrieve the creator document with the creator_id. And I think I'll do the same with the repiles doc from comments doc. I don't know if it's a good idea. If you will recommend me

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Firestore (like many NoSQL databases) does not support server-side joins (like you have in SQL databases).

If you want to display information for each user next to their comment (say, their name), you have two main options.

  • Either you load each user in your application code, often referred to as a client-side join. This is not as slow as you may think, but you'll want to make sure you optimize it properly (for example, by not loading the same user information over and over).
  • Or you ensure the information you need is already present in each comment document, so you duplicate the user's name in there. If you come from a SQL background this may seem like blasphemy, but it is actually quite idiomatic in NoSQL databases. In fact, it is part of the reason they can scale to so many read operations.

If you're new to this topic, I recommend checking out:

  • NoSQL data modeling, a primer on modeling data in many NoSQL databases.
  • Getting to know Cloud Firestore, a video series walking through many data modeling and code scenarios.
  • Firebase data structure and url
  • What is denormalization in Firebase Cloud Firestore?
  • How to write denormalized data in Firebase
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda